package com.gjs.reviewtree.web;

import lombok.Data;
import org.springframework.util.Assert;

/**
 * 通用返回结果
 * @param <T>
 */
@Data
public class CommonResult<T> {

    //返回码
    private Integer code;

    //返回数据
    private T data;

    //提示信息
    private String msg;


    public static <T> CommonResult<T> error(Integer code, String message) {
        CommonResult<T> result = new CommonResult<>();
        result.code = code;
        result.msg = message;
        return result;
    }

    public static <T> CommonResult<T> success(T data) {
        CommonResult<T> result = new CommonResult<>();
        result.code = 200;
        result.data = data;
        result.msg = "";
        return result;
    }

}
